<%-- 
    Document   : 
    Created on : 2016-7-5, 15:46:02
    Author     : cxhd
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="../../link.jsp"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>样本类型</title>
    </head>
     <style>
        tr>td{
            padding: 4px 4px 4px 4px;
            /*padding-bottom: 4px;*/
        }
        th{
            padding:4px 4px 4px 4px;
            font:bold;
            text-align:center;
        }
    </style>
    <body style="font-family: 微软雅黑;margin-top: 10px;" ng-app="sampletype" ng-controller="mainTab">
          <div class="col-lg-12">
            <div class="panel panel-default" style="overflow: hidden">

                <div class="panel-heading"><span style="float: left">用户列表</span>
                    <div>
                        <input ng-model="searchContent"  placeholder="名字/ID" style="width:320px; float: left;margin-left: 20px" class="form-control input-sm" />
                        <button ng-click="getList()" style="float: left" class="btn btn-success btn-sm"><span class="fa fa-search"></span>&nbsp;&nbsp;搜索</button>

                        <button ng-click="OpenSaveModal()" style="margin-left: 30px;float: left" class="btn btn-info btn-sm"><span class="fa fa-send"></span>&nbsp;&nbsp;添加</button></div>

                    <div style="clear: both"></div>
                </div>

                <table class="table table-striped table-bordered  table-hover ">
                    <thead>
                        <tr>
<!--                            <th class="table-id">用户ID</th>
                            <th class="table-title">用户名字</th>
                            <th class="table-type">性别</th>
                            <th class="table-author am-hide-sm-only">生日</th>
                            <th class="table-date am-hide-sm-only">部门</th>
                            <th class="table-set">操作</th>-->
                            <th class="table-id">序号</th>
                <!--<th class="table-title">代码</th>-->
                <th class="table-title">样本类型</th>
                <!--<th table-author>显示次序</th>-->
                <th class="table-date" >拼音</th>
                <!--<th class="table-date">自定义码</th>-->
                <th class="table-date">五笔码</th>
                <!--<th class="table-date">扩展类型</th>-->
                <th class="table-set">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                         <tr ng-repeat="list in lisSams">
                <!--SAMPLETYPE SAMPLEDESCRIBE TYPEORDER PY ZDM WB EXTENDTYPE-->
                <td>{{$index}}</td>
                <!--<td>{{list.SAMPLETYPE}}</td>--> 
                <td>{{list.SAMPLEDESCRIBE}}</td> 
                <!--<td>{{list.TYPEORDER}}</td>-->
                <td>{{list.PY}}</td>
                <!--<td>{{list.ZDM}}</td>-->
                <td>{{list.WB}}</td>
                <!--<td>{{list.EXTENDTYPE}}</td>-->
                <td>
                <button ng-click="OpenUpdateModal(list)" class="btn btn-success btn-xs"><span class="fa fa-edit"></span>修改</button>
                <button ng-click="deletePro(list)" class="btn btn-danger btn-xs"><span class="fa fa-bolt"></span>删除</button>
                </td>
            </tr>

                    </tbody>
                </table>
                <footer class="panel-heading">
                    <div class="row">
                        <div style="text-align: center" >                
                            <pagination ng-change="pageChanged()" previous-text="上一页" next-text="下一页" first-text="第一页" last-text="最后一页" ng-model="data.currentPage" items-per-page="data.pageSize" total-items="data.bigTotalItems" ng-model="data.bigCurrentPage" max-size="data.maxSize" class="pagination-sm" boundary-links="true" rotate="false" num-pages="numPages"></pagination>

                        </div>
                    </div>
                </footer>

            </div>

        </div>

        
            <div class="modal fade mode-x" role="dialog" aria-labelledby="gridSystemModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" ng-click="CloseModel()"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="gridSystemModalLabel">{{title}}样本类型</h4>
                    </div>
                    <div class="modal-body">
                        <form  name="profile" id="profile">
                            <table style="width: 100%">                             
                                <tr>  
                                   
                                <td>样本类型:</td><td colspan="2"><input ng-model="sam.SAMPLEDESCRIBE" style="font-size: 16px;font-weight:bold; " type="text" class="form-control"></td>
                                 <td>拼音:</td><td colspan="2"><input ng-model="sam.PY" type="text" style="font-size: 16px;font-weight:bold; " class="form-control"></td>
                                <!--<td>显示次序:</td><td><input ng-model="TYPEORDER"  style="font-size: 16px;font-weight:bold; width: 60px" type="text" class="form-control"></td><td>(数值）</td>-->
                                </tr>
                                <tr>
                               
                                <!--<td>自定义码:</td><td colspan="2"><input ng-model="ZDM" type="text" style="font-size: 16px;font-weight:bold; " class="form-control"></td>-->
                                <td>五笔码:</td><td colspan="2"><input ng-model="sam.WB" type="text" style="font-size: 16px;font-weight:bold; " class="form-control"></td>
                                 <td></td><td colspan="2">
                                     <!--<input ng-model="sam.SAMPLETYPE" id="sampletype" style="font-size: 16px;font-weight:bold; " type="text" class="form-control">-->
                                 </td>
                                 </tr>                        
<!--                                <tr>
                                <td>扩展类型:</td><td><input ng-model="EXTENDTYPE" style="font-size: 16px;font-weight:bold;width: 60px " type="text" class="form-control"></td><td>(数值）</td>
                                <td></td>
                                <td></td>
                                 </tr>-->
                            </table>
                        </form>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="CloseModel()">关闭</button>
                        <button  ng-click="savePro()"  type="button" class="btn btn-primary"><span class="fa fa-save"></span>&nbsp;&nbsp;保存</button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
        
        
    </body>
    <script>
         angular.module("sampletype", ['baseModule', 'ui.bootstrap'])
            .controller("mainTab", function ($scope,base) {
                var so = $scope;
                 $scope.sam={PK:""};
                 $scope.searchContent="";
                 
                $scope.data = {currentPage: 1};
                so.setPage = function (pageNo) {
                    $scope.data.currentPage = pageNo;
                };

                so.pageChanged = function () {
                    so.getList();
                };

                so.data.maxSize = 10;
                so.data.bigTotalItems = 20;
                so.data.bigCurrentPage = 1;
                so.data.pageSize = 10;

                $scope.getList = function () {
                    base.post("lisSam/getLisSampletype",{pageSize: so.data.pageSize, currentPage: so.data.currentPage,searchContent:$scope.searchContent}).get(function (data) {
//                          console.log(data);
                        if (data) {
                            so.lisSams = data.list;
                            so.data.bigTotalItems = data.totalRow;
//                            $scope.$apply();                            
                            
//                            so.data.bigTotalItems = data.totalRow; 
                        }
                    })
                };
                $scope.getList();
                $scope.deletePro=function(sam){// 必须判断什么情况下的数据不能删除
            
                    var gnl=confirm("你真的确定要删除吗?"); //友好提示
                if (gnl==true){ 
                    base.post("lisSam/deleteLisSampletype",{PK:sam.PK}).get(function(data){
                        if(data=='true'){
                            alert("删除成功！",1000);
                        }else{
                            alert("该数据被其他表使用不能删除",1000);
                        }
                        $scope.getList();
//                        $scope.$apply();
                    })
                 } else{ 
                return; 
                } 
                }
                 $scope.OpenSaveModal = function () {
                     $("#sampletype").prop("readonly",false);
                     $scope.title="新增";
                    $(".mode-x").modal('show');
                }
                $scope.OpenUpdateModal=function(list){
                      $scope.title="修改";
                       $("#sampletype").prop("readonly",true);
                       //<!--SAMPLETYPE SAMPLEDESCRIBE TYPEORDER PY ZDM WB EXTENDTYPE-->
                       $scope.sam=list;
                    $(".mode-x").modal('show');   
                }
               $scope.CloseModel=function(){//关闭窗口的同时清空窗口数据
                   $scope.sam={PK:""};
               }
               $scope.savePro=function(){//必须要验证 显示序号 和扩展类型为数值            
                   if($scope.SAMPLEDESCRIBE==""){//验证
                       alert("代码或样本类型不能为空",1000);
                       return;
                   }
 
                 base.post("lisSam/getLisSampletypeRep",$scope.sam).get(function(data){
                     if(data=='true'){
                         alert("代码或样本类型名称在数据库中已存在",1000);
                         return;
                     }
                
                 if($scope.sam.PK!=""&&$scope.sam.PK!=null){//修改
                     base.post("lisSam/updateLisSampletype",$scope.sam
                      ).get(function(data){
                      if(data='true'){
                          $scope.getList();
                          alert("修改成功！")
                      }
                         
                     })
                 }else{//保存 PROFILENAME PROFILECODE PROFILEDESCRIBE DEVICEID DATAWINDOWNAME SECTION
//                            //SAMPLETYPE DEFINPUT BJMC DEFNOTE DEFHYXM NOTES
                     base.post("lisSam/addLisSampletype",
                     $scope.sam).get(function(data){
                        if(data='true'){
                            $scope.getList();
                          alert("保存成功！")
                      }
                         
                     })
                 }
                 
                  $(".mode-x").modal('hide');
                 $scope.CloseModel();
                 $scope.getList();
                
                 })  
               }
            })
    </script>
</html>

